package com.photoveil;

import android.content.Context;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class TransparencySeekBarChangeListener implements OnSeekBarChangeListener {

	ChangeLog changeLog = ChangeLog.getInstance();
	int previousProgressValue;
	
	private Layer layer;
	
	public TransparencySeekBarChangeListener (Context context, Layer layer) {
		this.layer = layer;
		previousProgressValue = layer.getAlphaValue();
	}
	
	public void onProgressChanged(SeekBar seekBar, int progress,
			boolean fromUser) {
		layer.setAlphaValue(progress);
	}

	public void onStartTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub
		
	}

	public void onStopTrackingTouch(SeekBar seekBar) {
		Log.d("TransparencySeekBarChangeListener", "transparency: " + (int)((seekBar.getProgress()*100)/255));
		changeLog.addChange(new Change(layer, Change.CHANGE_TYPE_TRANSPARENCY, previousProgressValue, seekBar.getProgress()));
		previousProgressValue = seekBar.getProgress();
	}
	
	public void setLayer(Layer layer) {
		this.layer = layer;
		previousProgressValue = layer.getAlphaValue();
	}

}
